package com.fqgj.sentry.policy.enums;

import java.util.Arrays;

/**
 * Created by zwh @yuntu-inc.com
 *
 * @description
 * @create 2017/7/31 0031 上午 9:39
 */
public enum ColumnStatusEnum {
    field_system(1, "字段(系统)"),
    field_custom(2, "字段(自定义)"),
    field_grade(3, "字段(评分)"),
    fun_system(4, "函数(系统)"),
    fun_custom(5, "函数(自定义)");


    private Integer type;
    private String desc;

    ColumnStatusEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static String getDesc(Integer type) {
        for (ColumnStatusEnum columnStatusEnum : ColumnStatusEnum.values()) {
            if (columnStatusEnum.getType().equals(type)) {
                return columnStatusEnum.getDesc();
            }
        }
        return null;
    }

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public static ColumnStatusEnum getEnumByType(int type) {
        ColumnStatusEnum columnStatusEnum = null;
        for (ColumnStatusEnum e : ColumnStatusEnum.values()) {
            if (e.getType() == type) {
                return e;
            }
        }
        return columnStatusEnum;
    }

    public static Boolean isFun(Integer status) {
        return Arrays.asList(4, 5).contains(status);
    }
    public static Boolean isGrade(Integer status) {
        return status==3;
    }
}
